<%@ page import="raojt.day0109.lotteryProject.dao.LotteryBusinessDao" %>
<%@ page import="raojt.day0109.lotteryProject.dao.impl.LotteryBusinessDaoImpl" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="raojt.day0109.lotteryProject.entity.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 22770
  Date: 2023/1/9
  Time: 11:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>燃油汽车指标摇号系统</title>
    <link rel="stylesheet" type="text/css" href="../../../css/raojt/day0109/lottery.css"/>
    <script type="text/javascript" src="../../../js/raojt/day0109/User.js"></script>
    <script type="text/javascript" src="../../../js/raojt/day0109/jquery-3.6.3.js"></script>
    <script type="text/javascript" src="../../../js/raojt/day0109/addUser.js"></script>

    <%
        //jsp组成部分：jsp小脚本 内置对象(9个内置对象)  jsp指定  注释
        //在jsp页面中获取后端Java程序，进行数据交互
        //1.使用多态体现，实例化LotteryBusinessDao数据访问层
        LotteryBusinessDao lotteryBusinessDao = new LotteryBusinessDaoImpl();
        //2.创建Map集合对象，用来存储查询列表的搜索条件参数
        Map<String, Object> map = new HashMap<>();
        //获取indexController.jsp中存储在request作用域中的 searchName
        String searchName = request.getAttribute("searchName") == null ? "" :
                String.valueOf(request.getAttribute("searchName"));
        if (!"".equals(searchName)) {
            map.put("userMarkNo", searchName);
        }
        //3.调用查询列表方法
        List<User> usersLists = lotteryBusinessDao.selectAll(map);
    %>

</head>

<body>
<div class="population">
    <div class="top">
        <h1>燃油汽车指标摇号系统</h1>
    </div>
    <div class="middle">
        <div class="left">
            <button onclick="location.href='random.jsp'">参与摇号用户摇号</button>
        </div>
        <div class="right">
            <div class="top">
                <div class="leftButton">
                    <button onclick="location.href='addUser.jsp'">添加</button>
                </div>
                <form method="post" action="indexController.jsp">
                    <div class="rightButton">
                        <input type="text" placeholder="中签编码" name="search" id="search"/>
                        <button onclick="javascript:window.location.href='indexController.jsp'">搜索</button>
                    </div>
                </form>
            </div>
            <div class="middle">
                <ul>
                    <li>姓名</li>
                    <li>中签编码</li>
                    <li>持照状态</li>
                    <li>手机号码</li>
                    <li>开户日期</li>
                    <li>操作</li>
                </ul>
            </div>
            <div class="last">
                <form method="post" action="deleteController.jsp">
                <%
                    for (int i = 0; i < usersLists.size(); i++) {
                        String status = usersLists.get(i).getStatus();
                        if ("0".equals(status)) {
                            status = "已持照";
                        } else {
                            status = "未持照";
                        }
                %>
                <ul>
                    <li name="name"><%=usersLists.get(i).getUserName()%>
                    </li>
                    <li name="markNo"><%=usersLists.get(i).getMarkNo()%>
                    </li>
                    <li><%=status%>
                    </li>
                    <li><%=usersLists.get(i).getPhone()%>
                    </li>
                    <li><%=usersLists.get(i).getOpenDate()%>
                    </li>
                    <li><a href="javascript:void(0);">详情</a>&nbsp;&nbsp;
                        <a href="deleteController.jsp?markNo=<%=usersLists.get(i).getMarkNo()%>" class="del">删除</a>
                    </li>
                </ul>
                <%
                    }
                %>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>
